<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link href="/static/v5/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link href="/static/v5/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
    <link href="/static/v5/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/static/v5/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/v5/css/kkpager_blue.css" />
    <title></title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 黑名单管理 <span class="c-gray en">&gt;</span> 黑名单列表  <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

    <div >
        <a th:href="${'/v5/black/to/add?token='  + token + '&black_type=' + retInfo.obj.black_type+ '&black_object_id=' + retInfo.obj.black_object_id}" >
            <button type="submit" class="btn btn-success radius" id="" name="">
                <i class="Hui-iconfont">&#xe600;</i>添加
            </button>
        </a>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="50">id</th>
                <th width="100">状态</th>
                <th width="100">添加时间</th>
                <th width="50">黑名单原因</th>
                <th width="50">解除黑名单时间</th>
                <th width="50">解除原因</th>

                <th width="100">操作</th>
            </tr>
            </thead>

                <tbody >
                <th:block  th:each="bean: ${retInfo.obj.list}">
                    <tr class="text-c" id="table">
                        <td th:text="${bean.black_id}"></td>
                        <td>
                            <th:block th:if="${bean.state == 1}">黑名单</th:block>
                            <th:block th:if="${bean.state == 2}">解除黑名单</th:block>
                        </td>
                        <td th:text="${#dates.format(bean.add_time, 'yyyy-MM-dd HH:mm:ss')}"></td>
                        <td th:text="${bean.black_why}"></td>

                        <td >
                            <th:block th:if="${bean.state == 2}" th:text="${#dates.format(bean.remove_time, 'yyyy-MM-dd HH:mm:ss')}"></th:block>
                        </td>
                        <td th:text="${bean.remove_black_why}"></td>

                        <td class="td-manage">
                            <th:block th:if="${bean.state == 1}">
                                <a href="###"  th:onclick="|updateValid(this ,${bean.black_id})|"> 解除黑名单</a>
                            </th:block>


                        </td>
                    </tr>
                </th:block>
            </tbody>
        </table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/v5/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/v5/js/kkpager.js"></script>
<script type="text/javascript" src="/static/v5/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/v5/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/v5/lib/layer/2.4/layer.js"></script>
<div th:if="${retInfo.mark == '0'}">
    <div style="margin: 0px 20px 0px 20px">
        <div id="kkpager"></div>
    </div>
    <script  th:inline="javascript">
        /*<![CDATA[*/
        var totalPage = [[${retInfo.obj.total_page}]];
        var totalRecords = [[${retInfo.obj.total_record}]];
        var pageNo = [[${retInfo.obj.current_page}]];
        var page_size = [[${retInfo.obj.page_size}]];
        var father_id = [[${father_id}]];
        var black_type = [[${retInfo.obj.black_type}]];
        var black_object_id = [[${retInfo.obj.black_object_id}]];
        /*]]>*/
        //init
        $(function() {

            if(!pageNo){
                pageNo = 1;
            }
            //生成分页
            //有些参数是可选的，比如lang，若不传有默认值
            kkpager.generPageHtml({
                pno : pageNo,
                //总页码
                total : totalPage,
                //总数据条数
                totalRecords : totalRecords,

                getLink : function(n){
                    var href = "/v5/black/list" + "?page_size=" + page_size + "&father_id="+ father_id + "&current_page=" + n + "&token="  + sessionStorage.getItem("token")
                     "&black_type=" + black_type +    "&black_object_id=" + black_object_id
                    return href;
                }

            });
        });

        function updateValid(bj ,black_id) {
            var   msg = "解除原因<textarea id=\"audit_remark\" name=\"\" cols=\"\" rows=\"\" class=\"textarea\" datatype=\"*10-100\" dragonfly=\"true\"\n" +
                "></textarea>";
            layer.confirm(msg ,function(index){
                if($("#audit_remark").val()==null||$("#audit_remark").val()==""){
                    alert("解除原因不能为空");
                    return;
                }
                if($("#audit_remark").val().length > 500){
                    alert("解除原因最多500个字符");
                    return;
                }
                var data = "black_id=" + black_id + "&remove_black_why=" + $("#audit_remark").val()  + "&token="  + sessionStorage.getItem("token");
                $.ajax({
                    type:'post',
                    url:'/v5/black/update',
                    dataType : 'json',
                    data: data,
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success:function(data){
                        if (data.mark=="0") {
                            window.location.reload();

                        } else {
                            alert(data.tip);
                        }
                    },
                    error: function(textStatus) {
                        alert(textStatus);
                    }

                });
            });

        }
    </script>
</div>

</body>
</html>
